export const splitString: SplitString = (str, { chunk, separator } = {}) =>
  str.length > 4
    ? str
        .match(RegExp(`.{1,${chunk ?? (str.length % 4 === 0 ? 4 : str.length % 3 === 0 ? 3 : 2)}}`, 'g'))
        ?.join(separator ?? '\u00A0') || ''
    : str;

interface SplitString {
  (
    str: string,
    opts?: {
      readonly chunk?: number;
      readonly separator?: string;
    }
  ): string;
}
